package siga.visao_financeiro;

import java.math.BigDecimal;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;
import siga.banco.conexao;
import siga.criptografia.NumeroStr;
import siga.navegadores.navegador;
import siga.visao.index;
import siga.visao.verErros;
import siga.visao_busca.buscaVer;
import siga.visao_busca.buscaDocFinVer;


public class movContasReceber extends javax.swing.JInternalFrame {
    Object[] JOopcoes = {"Sim","Não"};
    List CodObs = new ArrayList();
    List cod_turma = new ArrayList();
    boolean busca_direta = false;

    public movContasReceber() {
            initComponents();
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpmObs = new javax.swing.JPopupMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jpmBoleto = new javax.swing.JPopupMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jpCRPrincipal = new javax.swing.JPanel();
        jpMenu = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jtfTipoBusca = new javax.swing.JComboBox();
        jToolBar1 = new javax.swing.JToolBar();
        jButton6 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jtfTurma = new javax.swing.JComboBox();
        jToolBar2 = new javax.swing.JToolBar();
        jbBaixar = new javax.swing.JButton();
        jbEstornar = new javax.swing.JButton();
        jbCancelar = new javax.swing.JButton();
        jbEditar = new javax.swing.JButton();
        jbNegociar = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jpTable = new javax.swing.JPanel();
        jspCaixa = new javax.swing.JScrollPane();
        jtCaixa = new javax.swing.JTable();
        jpObs = new javax.swing.JPanel();
        jspObs = new javax.swing.JScrollPane();
        jtObs = new javax.swing.JTable();

        jpmObs.setName("jpmObs"); // NOI18N

        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/obs_inserir_16x16.png"))); // NOI18N
        jMenuItem1.setText("Inserir Observação");
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jpmObs.add(jMenuItem1);

        jMenuItem3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/obs_remover_16x16.png"))); // NOI18N
        jMenuItem3.setText("Remover Observação");
        jMenuItem3.setName("jMenuItem3"); // NOI18N
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jpmObs.add(jMenuItem3);

        jpmBoleto.setName("jpmBoleto"); // NOI18N

        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/relatorio_16x16.png"))); // NOI18N
        jMenuItem2.setText("Imprimir Recibo");
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jpmBoleto.add(jMenuItem2);

        jMenuItem4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/JDateChooserColor16.gif"))); // NOI18N
        jMenuItem4.setText("Alterar Datas");
        jMenuItem4.setToolTipText("Altera todas as Datas dos Boletos não Baixados");
        jMenuItem4.setName("jMenuItem4"); // NOI18N
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jpmBoleto.add(jMenuItem4);

        jMenuItem5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/cheque_16x16.png"))); // NOI18N
        jMenuItem5.setText("Alterar Valor Bruto");
        jMenuItem5.setToolTipText("Alterar o valor bruto de todos os boletos não baixados");
        jMenuItem5.setName("jMenuItem5"); // NOI18N
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jpmBoleto.add(jMenuItem5);

        jMenuItem6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jMenuItem6.setText("Ver Dados do Boleto");
        jMenuItem6.setName("jMenuItem6"); // NOI18N
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jpmBoleto.add(jMenuItem6);

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Contas a Receber");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/contasreceber_16x16.png"))); // NOI18N
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameActivated(evt);
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        jpCRPrincipal.setName("jpCRPrincipal"); // NOI18N

        jpMenu.setName("jpMenu"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Tipo de Visão"));
        jPanel1.setName("jPanel1"); // NOI18N

        jtfTipoBusca.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Todos", "Recebida", "A Receber", "Parcial", "Renegociado" }));
        jtfTipoBusca.setName("jtfTipoBusca"); // NOI18N
        jtfTipoBusca.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jtfTipoBuscaItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jtfTipoBusca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jtfTipoBusca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/buscar_32x32.png"))); // NOI18N
        jButton6.setText("Busca");
        jButton6.setToolTipText("Busca por Pessoas");
        jButton6.setFocusable(false);
        jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton6.setName("jButton6"); // NOI18N
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton6);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/buscar_32x32.png"))); // NOI18N
        jButton2.setText("Acadêmico");
        jButton2.setToolTipText("Busca somente Acadêmicos");
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton2);

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/buscar_32x32.png"))); // NOI18N
        jButton3.setText("Docente");
        jButton3.setToolTipText("Busca somente Docentes");
        jButton3.setFocusable(false);
        jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton3.setName("jButton3"); // NOI18N
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton3);

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/buscar_32x32.png"))); // NOI18N
        jButton4.setText("Fornecedor");
        jButton4.setToolTipText("Busca somente Fornecedores");
        jButton4.setFocusable(false);
        jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton4.setName("jButton4"); // NOI18N
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton4);

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/buscar_32x32.png"))); // NOI18N
        jButton5.setText("Funcionário");
        jButton5.setFocusable(false);
        jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton5.setName("jButton5"); // NOI18N
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton5);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_doc_32x32.png"))); // NOI18N
        jButton1.setText("Busca Boleto");
        jButton1.setToolTipText("Busca por Documento");
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton1);

        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/relatorio_32x32.png"))); // NOI18N
        jButton8.setText("Impressão");
        jButton8.setFocusable(false);
        jButton8.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton8.setName("jButton8"); // NOI18N
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton8);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Turma/Módulo"));
        jPanel2.setName("jPanel2"); // NOI18N

        jtfTurma.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Todos" }));
        jtfTurma.setName("jtfTurma"); // NOI18N
        jtfTurma.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jtfTurmaItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jtfTurma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(44, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jtfTurma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(26, Short.MAX_VALUE))
        );

        jToolBar2.setFloatable(false);
        jToolBar2.setRollover(true);
        jToolBar2.setName("jToolBar2"); // NOI18N

        jbBaixar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/baixar_32x32.png"))); // NOI18N
        jbBaixar.setText("Baixar");
        jbBaixar.setEnabled(false);
        jbBaixar.setFocusable(false);
        jbBaixar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbBaixar.setName("jbBaixar"); // NOI18N
        jbBaixar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbBaixar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBaixarActionPerformed(evt);
            }
        });
        jToolBar2.add(jbBaixar);

        jbEstornar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/estornar_32x32.png"))); // NOI18N
        jbEstornar.setText("Estornar");
        jbEstornar.setEnabled(false);
        jbEstornar.setFocusable(false);
        jbEstornar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbEstornar.setName("jbEstornar"); // NOI18N
        jbEstornar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbEstornar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbEstornarActionPerformed(evt);
            }
        });
        jToolBar2.add(jbEstornar);

        jbCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/cxCancelar_32x32.png"))); // NOI18N
        jbCancelar.setText("Remover");
        jbCancelar.setEnabled(false);
        jbCancelar.setFocusable(false);
        jbCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbCancelar.setName("jbCancelar"); // NOI18N
        jbCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelarActionPerformed(evt);
            }
        });
        jToolBar2.add(jbCancelar);

        jbEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/cxEditar_32x32.png"))); // NOI18N
        jbEditar.setText("Alterar");
        jbEditar.setEnabled(false);
        jbEditar.setFocusable(false);
        jbEditar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbEditar.setName("jbEditar"); // NOI18N
        jbEditar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbEditarActionPerformed(evt);
            }
        });
        jToolBar2.add(jbEditar);

        jbNegociar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/negociacao_32x32.png"))); // NOI18N
        jbNegociar.setText("Negociar");
        jbNegociar.setEnabled(false);
        jbNegociar.setFocusable(false);
        jbNegociar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbNegociar.setName("jbNegociar"); // NOI18N
        jbNegociar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbNegociar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbNegociarActionPerformed(evt);
            }
        });
        jToolBar2.add(jbNegociar);

        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/gerar_men_32x32.png"))); // NOI18N
        jButton7.setText("Novo");
        jButton7.setToolTipText("Criar Menssalidades");
        jButton7.setFocusable(false);
        jButton7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton7.setName("jButton7"); // NOI18N
        jButton7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        jToolBar2.add(jButton7);

        javax.swing.GroupLayout jpMenuLayout = new javax.swing.GroupLayout(jpMenu);
        jpMenu.setLayout(jpMenuLayout);
        jpMenuLayout.setHorizontalGroup(
            jpMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 930, Short.MAX_VALUE)
            .addGroup(jpMenuLayout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, 699, Short.MAX_VALUE))
        );
        jpMenuLayout.setVerticalGroup(
            jpMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpMenuLayout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jToolBar2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)))
        );

        jpTable.setName("jpTable"); // NOI18N

        jspCaixa.setName("jspCaixa"); // NOI18N

        jtCaixa.setFont(new java.awt.Font("SansSerif", 0, 10));
        jtCaixa.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Pessoa", "Código Pessoa", "Parc.", "Dt. Venc.", "Bruto", "Juros", "Desconto", "Saldo", "Dt. Pag.", "Pago", "Situação"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtCaixa.setComponentPopupMenu(jpmBoleto);
        jtCaixa.setName("jtCaixa"); // NOI18N
        jtCaixa.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                TabelaLinhaSelecionada(evt);
            }
        });
        jspCaixa.setViewportView(jtCaixa);
        jtCaixa.getColumnModel().getColumn(0).setPreferredWidth(50);
        jtCaixa.getColumnModel().getColumn(0).setMaxWidth(50);
        jtCaixa.getColumnModel().getColumn(2).setPreferredWidth(90);
        jtCaixa.getColumnModel().getColumn(2).setMaxWidth(90);
        jtCaixa.getColumnModel().getColumn(3).setPreferredWidth(35);
        jtCaixa.getColumnModel().getColumn(3).setMaxWidth(35);
        jtCaixa.getColumnModel().getColumn(4).setPreferredWidth(70);
        jtCaixa.getColumnModel().getColumn(4).setMaxWidth(70);
        jtCaixa.getColumnModel().getColumn(5).setPreferredWidth(60);
        jtCaixa.getColumnModel().getColumn(5).setMaxWidth(60);
        jtCaixa.getColumnModel().getColumn(6).setPreferredWidth(60);
        jtCaixa.getColumnModel().getColumn(6).setMaxWidth(60);
        jtCaixa.getColumnModel().getColumn(7).setPreferredWidth(60);
        jtCaixa.getColumnModel().getColumn(7).setMaxWidth(60);
        jtCaixa.getColumnModel().getColumn(8).setPreferredWidth(70);
        jtCaixa.getColumnModel().getColumn(8).setMaxWidth(70);
        jtCaixa.getColumnModel().getColumn(9).setPreferredWidth(70);
        jtCaixa.getColumnModel().getColumn(9).setMaxWidth(70);
        jtCaixa.getColumnModel().getColumn(10).setPreferredWidth(60);
        jtCaixa.getColumnModel().getColumn(10).setMaxWidth(60);
        jtCaixa.getColumnModel().getColumn(11).setPreferredWidth(70);
        jtCaixa.getColumnModel().getColumn(11).setMaxWidth(70);

        javax.swing.GroupLayout jpTableLayout = new javax.swing.GroupLayout(jpTable);
        jpTable.setLayout(jpTableLayout);
        jpTableLayout.setHorizontalGroup(
            jpTableLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jspCaixa, javax.swing.GroupLayout.DEFAULT_SIZE, 930, Short.MAX_VALUE)
        );
        jpTableLayout.setVerticalGroup(
            jpTableLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jspCaixa, javax.swing.GroupLayout.DEFAULT_SIZE, 467, Short.MAX_VALUE)
        );

        jpObs.setBorder(javax.swing.BorderFactory.createTitledBorder("Observações Cadastradas"));
        jpObs.setName("jpObs"); // NOI18N

        jspObs.setName("jspObs"); // NOI18N

        jtObs.setFont(new java.awt.Font("DejaVu Sans", 0, 12));
        jtObs.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Usuário", "Data", "Observação"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtObs.setComponentPopupMenu(jpmObs);
        jtObs.setName("jtObs"); // NOI18N
        jspObs.setViewportView(jtObs);
        jtObs.getColumnModel().getColumn(0).setPreferredWidth(150);
        jtObs.getColumnModel().getColumn(0).setMaxWidth(150);
        jtObs.getColumnModel().getColumn(1).setPreferredWidth(80);
        jtObs.getColumnModel().getColumn(1).setMaxWidth(80);

        javax.swing.GroupLayout jpObsLayout = new javax.swing.GroupLayout(jpObs);
        jpObs.setLayout(jpObsLayout);
        jpObsLayout.setHorizontalGroup(
            jpObsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jspObs, javax.swing.GroupLayout.DEFAULT_SIZE, 918, Short.MAX_VALUE)
        );
        jpObsLayout.setVerticalGroup(
            jpObsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jspObs, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jpCRPrincipalLayout = new javax.swing.GroupLayout(jpCRPrincipal);
        jpCRPrincipal.setLayout(jpCRPrincipalLayout);
        jpCRPrincipalLayout.setHorizontalGroup(
            jpCRPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpMenu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jpObs, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jpTable, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jpCRPrincipalLayout.setVerticalGroup(
            jpCRPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpCRPrincipalLayout.createSequentialGroup()
                .addComponent(jpMenu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpTable, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpObs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpCRPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpCRPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        buscaVer.setTipo("Academico");
        OpenBuscaVer();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        buscaVer.setTipo("Funcionario");
        OpenBuscaVer();
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        buscaVer.setTipo("Docente");
        OpenBuscaVer();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        buscaVer.setTipo("Fornecedor");
        OpenBuscaVer();
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        buscaVer.setTipo("");
        OpenBuscaVer();
    }//GEN-LAST:event_jButton6ActionPerformed

    private void TabelaLinhaSelecionada(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TabelaLinhaSelecionada
        if(evt.getClickCount()==2){
            BaixarBoleto();
        }else if(!jbBaixar.isEnabled()){
            setBotoes();
            CarregaObs();
        }else if(index.LRpessoa.get(0).equals("")){
            CarregaObs();
        }
    }//GEN-LAST:event_TabelaLinhaSelecionada

    private void jbBaixarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBaixarActionPerformed
        busca_direta=true;
        BaixarBoleto();
    }//GEN-LAST:event_jbBaixarActionPerformed

    private void jbEstornarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbEstornarActionPerformed
        if(JOptionPane.showOptionDialog(null, "Deseja estornar o boleto de número:"+jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 0)+"?","Estorno",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,JOopcoes,JOopcoes[0])==JOptionPane.YES_OPTION){
            try {
                busca_direta=true;
                conexao.stm.executeUpdate("update fin_contas_mov_r set status=\"A Receber\", cod_usuario="+index.usuario[0]+",cod_caixa=null,dt_pagamento=null,valor_juro_dia=null,valor_desconto=null,valor_pago=null " +
                        "where  codigo="+jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 0)+" and cod_emp="+index.cod_emp);
                conexao.stm.executeUpdate("update fin_caixa set banco_vl_atual=banco_vl_atual-"+index.ftes.parse(jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 10).toString()).doubleValue()+" where codigo="+index.usuario[0]+" and cod_emp="+index.cod_emp);
                CarregaTabela();
            } catch (ParseException ex) {
                verErros.setErro(ex.getMessage());
            } catch (SQLException ex) {
                verErros.setErro(ex.getMessage());
            }
       }else{
            JOptionPane.showMessageDialog(null, "Operação Cancelada.","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
       }
    }//GEN-LAST:event_jbEstornarActionPerformed

    private void jbCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelarActionPerformed
        int[] x = jtCaixa.getSelectedRows();
        if (jtCaixa.getSelectedRowCount() < 1) {
            if (JOptionPane.showOptionDialog(null, "Deseja cancelar o boleto de número:" + jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 0) + "?\nEsta ação implica em remover o registros financeiros da pessoa.", "Cancelamento", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, JOopcoes, JOopcoes[0]) == JOptionPane.YES_OPTION) {
                try {
                    busca_direta=true;
                    conexao.stm.executeUpdate("delete from fin_contas_mov_r where cod_emp=" + index.cod_emp + " and codigo=" + jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 0));
                    JOptionPane.showMessageDialog(null, "Cancelamento efetuado.", "Cancelamento", JOptionPane.INFORMATION_MESSAGE);
                } catch (SQLException ex) {
                    verErros.setErro(ex.getMessage());
                }
            }
        } else {
            String stBoleto="";
            for (int i = 0; i < jtCaixa.getSelectedRowCount(); i++) {
                stBoleto += jtCaixa.getValueAt(x[i], 0) + ",";
            }
            if (JOptionPane.showOptionDialog(null, "Deseja cancelar os boletos de número:\n" + stBoleto + "?\nEsta ação implica em remover o registros financeiros da pessoa.", "Cancelamento", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, JOopcoes, JOopcoes[0]) == JOptionPane.YES_OPTION) {
                try {
                    busca_direta=true;
                    for (int i = 0; i < jtCaixa.getSelectedRowCount(); i++) {
                        conexao.stm.executeUpdate("delete from fin_contas_mov_r where cod_emp=" + index.cod_emp + " and codigo=" + jtCaixa.getValueAt(x[i], 0));
                    }
                    JOptionPane.showMessageDialog(null, "Cancelamento efetuado.", "Cancelamento", JOptionPane.INFORMATION_MESSAGE);
                } catch (SQLException ex) {
                    verErros.setErro(ex.getMessage());
                }
            }
        }
        CarregaTabela();
    }//GEN-LAST:event_jbCancelarActionPerformed

    private void jbEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbEditarActionPerformed
        if(jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 11).equals("A Receber")||jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 11).equals("Vencida")||jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 11).equals("Parcial")){
            busca_direta=true;
            java.awt.Dimension tela = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            movCaixaEditarVer mcev = new movCaixaEditarVer(null,true);
            mcev.setLocation((tela.width-mcev.getWidth())/2, (tela.height-mcev.getHeight())/2);
            mcev.cod_lanc = jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 0).toString();
            mcev.cod_pessoa.add(0,jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 2).toString());
            mcev.cod_pessoa.add(1,jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 1).toString());
            mcev.setVisible(true);
            if(movCaixaEditarVer.isConfirmaEditar()){
                setBotoes();
                CarregaTabela();
            }
        }else{
            JOptionPane.showMessageDialog(null, "Não é possível editar.\n Situação:"+jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 11),"Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_jbEditarActionPerformed

    private void jtfTipoBuscaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jtfTipoBuscaItemStateChanged
        CarregaTabela();
    }//GEN-LAST:event_jtfTipoBuscaItemStateChanged

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        LimpaCarregaObs();
        buscaDocFinVer bdfv = new buscaDocFinVer(null,true);
        bdfv.setLocation((index.tela.width-bdfv.getWidth())/2, (index.tela.height-bdfv.getHeight())/2);
        bdfv.setVisible(true);
        if(buscaDocFinVer.isConfirmaBuscaDoc()){
            if(jbBaixar.isEnabled())
                setBotoes();
            busca_direta=true;
            CarregaTabela();
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        if(jtObs.getSelectedRowCount()>0){
            if (JOptionPane.showOptionDialog(null, "Deseja remover esta Observação?", "Observações", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, JOopcoes, JOopcoes[0]) == JOptionPane.YES_OPTION) {
                try {
                    conexao.stm.executeUpdate("delete from fin_obs where codigo="+CodObs.get(jtObs.getSelectedRow())+" and cod_emp="+index.cod_emp);
                    JOptionPane.showMessageDialog(null, "Operação realizada.","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
                    CarregaObs();
                } catch (SQLException ex) {
                    verErros.setErro(ex.getMessage());
                }
            }
        }else{
            JOptionPane.showMessageDialog(null, "Operação cancelada.","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        java.awt.Dimension tela = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        movObsVer mov = new movObsVer(null,true);
        mov.setLocation((tela.width-mov.getWidth())/2, (tela.height-mov.getHeight())/2);
        mov.setVisible(true);
        if(movObsVer.isConfirmaObs()){
            CarregaObs();
        }
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        if(jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 11).equals("Recebida")){
            try {
                NumeroStr nrconv = new NumeroStr(new BigDecimal(jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 10).toString().replace(',', '.')));
                HashMap parametro = new HashMap();
                parametro.put("desc_emp", index.empresa.get(0).toString());
                parametro.put("cnpj_emp", index.empresa.get(1).toString());
                parametro.put("end_emp", index.empresa.get(2).toString());
                parametro.put("bairro_emp", index.empresa.get(3).toString());
                parametro.put("cidade_emp", index.empresa.get(4).toString());
                parametro.put("uf_emp", index.empresa.get(5).toString());
                parametro.put("tel_emp", index.empresa.get(6).toString());
                parametro.put("tel2_emp", index.empresa.get(7).toString());
                parametro.put("email_emp", index.empresa.get(8).toString());
                parametro.put("DtPag", jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 9));
                parametro.put("DtVenc", jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 4));
                parametro.put("NomePessoa", "["+jtCaixa.getValueAt(jtCaixa.getSelectedRow(),2)+"] "+jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 1));
                parametro.put("Valor", jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 10));
                parametro.put("ValorEscrito", nrconv.toString().toUpperCase());
                parametro.put("Parcela", jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 3));
                if(jtfTurma.getSelectedItem().toString().equals("Todos")){
                    parametro.put("turma", jtfTurma.getItemAt(1).toString());
                }else{
                    parametro.put("turma", jtfTurma.getSelectedItem().toString());
                }
                
                JasperPrint jp = JasperFillManager.fillReport(System.getProperty("user.dir")+"/relatorios/relCaixaRecibo.jasper", parametro);
                JasperViewer.viewReport(jp, false);
            } catch (JRException ex) {
                verErros.setErro(ex.getMessage());
            }
        }else{
            JOptionPane.showMessageDialog(null, "Permitido somente conta recebida","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jtfTurmaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jtfTurmaItemStateChanged
         if(jtfTurma.getItemCount()>1){
            if(jtCaixa.getSelectedRowCount() > 0){
                index.LRpessoa.add(0,jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 2).toString());
                index.LRpessoa.add(1,jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 1).toString());
            }
            CarregaTabela();
         }
    }//GEN-LAST:event_jtfTurmaItemStateChanged

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        if (jtCaixa.getSelectedRowCount() > 1) {
            movContasAlterarDatas mcad = new movContasAlterarDatas(null,true);
            mcad.setLocation((index.tela.width-mcad.getWidth())/2, (index.tela.height-mcad.getHeight())/2);
            int[] x = jtCaixa.getSelectedRows();
            for (int i=0; i < jtCaixa.getSelectedRowCount(); i++) {
                movContasAlterarDatas.cadcodigo.add(jtCaixa.getValueAt(x[i], 0));
            }
            mcad.setVisible(true);
            if(movContasAlterarDatas.isConfirmaData()){
                CarregaTabela();
            }
        }
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        movContasAlterarValor mcav = new movContasAlterarValor(null,true);
        mcav.setLocation((index.tela.width-mcav.getWidth())/2, (index.tela.height-mcav.getHeight())/2);
        movContasAlterarValor.cod_pessoa=jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 2).toString();
        movContasAlterarValor.cod_matricula=(jtfTurma.getSelectedItem().toString().equals("Todos"))? "" : jtfTurma.getSelectedItem().toString().substring(0, jtfTurma.getSelectedItem().toString().length()-2);
        movContasAlterarValor.cod_fase=(jtfTurma.getSelectedItem().toString().equals("Todos"))? "" : jtfTurma.getSelectedItem().toString().substring(jtfTurma.getSelectedItem().toString().length()-1, jtfTurma.getSelectedItem().toString().length());
        mcav.setVisible(true);
        if(movContasAlterarValor.isConfirmaValor()){
            CarregaTabela();
        }
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        movCaixaGerar mcg = new movCaixaGerar(null,true);
        mcg.setLocation((index.tela.width-mcg.getWidth())/2, (index.tela.height-mcg.getHeight())/2);
        mcg.setVisible(true);
        if(movCaixaGerar.isConfirmaGerar()){
            CarregaTabela();
        }
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jbNegociarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbNegociarActionPerformed
        movNegociar mvna = new movNegociar(null,true);
        mvna.setLocation((index.tela.width-mvna.getWidth())/2, (index.tela.height-mvna.getHeight())/2);
        mvna.setVisible(true);
        if(movNegociar.finalizar){
            CarregaTabela();
        }
    }//GEN-LAST:event_jbNegociarActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
          navegador.URL("http://201.35.207.198/sistema/relatorios/relatorio_fin_contas_receber.php?sql= and p.codigo="+index.LRpessoa.get(0)+"&cod_emp="+index.cod_emp);
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        movContasReceverVerBoleto mv = new movContasReceverVerBoleto(null,true);
        mv.setLocation((index.tela.width-mv.getWidth())/2, (index.tela.height-mv.getHeight())/2);
        mv.cod_boleto=jtCaixa.getValueAt(jtCaixa.getSelectedRow(),0).toString();
        mv.setVisible(true);
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void formInternalFrameActivated(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameActivated
        if(jtCaixa.getSelectedRowCount() > 0){
            index.LRpessoa.add(0,jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 2).toString());
            index.LRpessoa.add(1,jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 1).toString());
        }
    }//GEN-LAST:event_formInternalFrameActivated

    protected void OpenBuscaVer(){
        buscaVer bv = new buscaVer(null,true);
        bv.setLocation((index.tela.width-bv.getWidth())/2, (index.tela.height-bv.getHeight())/2);
        bv.setVisible(true);
        if(buscaVer.isConfirmaBusca()){
            jtfTurma.removeAllItems();
            jtfTurma.addItem("Todos");
            //index.LimpaCampos();
            LimpaCarregaObs();
            if(jbBaixar.isEnabled()){
                setBotoes();
            }
            CarregaTabela();
        }
    }

    public void BaixarBoleto(){
        if(jtCaixa.getSelectedRowCount() > 0){
            if(jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 11).equals("A Receber")||jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 11).equals("Vencida")||jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 11).equals("Parcial")){
                movCaixaBaixarVer mcbv = new movCaixaBaixarVer(null,true);
                mcbv.setLocation((index.tela.width-mcbv.getWidth())/2, (index.tela.height-mcbv.getHeight())/2);
                mcbv.Codigo = jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 0).toString();
                mcbv.Nome = "["+jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 2).toString()+"]"+jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 1).toString();
                mcbv.Desconto = jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 7).toString();
                mcbv.DtVenc = jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 4).toString();
                mcbv.Juro = jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 6).toString();
                mcbv.Valor = jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 5).toString();
                mcbv.Parcela = jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 3).toString();
                mcbv.setVisible(true);
                if(movCaixaBaixarVer.isConfirmaBaixa()){
                    setBotoes();
                    CarregaTabela();
                }
            }else{
                JOptionPane.showMessageDialog(null, "Não é possível receber.\n Situação:"+jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 11),"Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
            }
        }else{
          JOptionPane.showMessageDialog(null, "Selecione uma linha.","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
        }
    }

    public void CarregaTabela(){
        if(!index.LRpessoa.get(0).equals("")||busca_direta==true){
            try {
                String vtipobusca;
                String vturma;
                String vpessoa;
                String vnrdoc;
                String vdtvenc;
                String vdtpag;
                String vvlbr;
                String vvlrec;
                String vfase;
                String vdescricao;
                String vdtvencperiodo;
                String vdtpgtoperiodo;
                String dtTabela1;
                String dtTabela2;
                javax.swing.table.DefaultTableModel jtb = (javax.swing.table.DefaultTableModel) jtCaixa.getModel();
                for (int x = jtCaixa.getRowCount() - 1; x >= 0; --x) {
                    jtb.removeRow(x);
                }
                vtipobusca = (jtfTipoBusca.getSelectedItem().equals("Todos")) ? "" : " and fr.status=\"" + jtfTipoBusca.getSelectedItem() + "\"";
                vturma = (jtfTurma.getSelectedItem().equals("Todos")) ? "" : " and fr.cod_matricula=\"" + jtfTurma.getSelectedItem().toString().substring(0, jtfTurma.getSelectedItem().toString().length() - 2) + "\"";
                vfase = (jtfTurma.getSelectedItem().equals("Todos")) ? "" : " and fr.cod_fase=" + jtfTurma.getSelectedItem().toString().substring(jtfTurma.getSelectedItem().toString().length() - 1, jtfTurma.getSelectedItem().toString().length());
                vpessoa = (index.LRpessoa.isEmpty()) ? "" : " and fr.cod_pessoa=" + index.LRpessoa.get(0);
                vnrdoc = (index.pesquisa.isEmpty()) ? "" : " and fr.codigo=" + index.pesquisa.get(0);
                vdtvenc = (index.pesquisa.isEmpty()) ? "" : new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat("dd/MM/yyyy").parse(index.pesquisa.get(1).toString()));
                vdtvenc = (vdtvenc.equals("")) ? "" : " and fr.dt_vencimento like \"" + vdtvenc + "%\"";
                vdtpag = (index.pesquisa.isEmpty()) ? "" : new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat("dd/MM/yyyy").parse(index.pesquisa.get(2).toString()));
                vdtpag = (vdtpag.equals("")) ? "" : " and fr.dt_pagamento like \"" + vdtpag + "%\"";
                vvlbr = (index.pesquisa.isEmpty()) ? "" : " and fr.valor_bruto=\"" + index.ftes.parse(index.pesquisa.get(3).toString()).doubleValue() + "\"";
                vvlrec = (index.pesquisa.isEmpty()) ? "" : " and fr.valor_pago=\"" + index.ftes.parse(index.pesquisa.get(4).toString()).doubleValue() + "\"";
                vdescricao = (index.pesquisa.isEmpty()) ? "" : " and fr.descricao like \"%"+index.pesquisa.get(5)+"%\"";
                vdtpgtoperiodo = (index.pesquisa.isEmpty())?"":" and (fr.dt_pagamento BETWEEN \""+index.dtcv.converte("US", index.pesquisa.get(8).toString())+" 00:00:00\" and \""+index.dtcv.converte("US", index.pesquisa.get(9).toString())+" 23:59:59\") ";
                vdtvencperiodo = (index.pesquisa.isEmpty())?"":" and (fr.dt_vencimento BETWEEN \""+index.dtcv.converte("US", index.pesquisa.get(6).toString())+" 00:00:00\" and \""+index.dtcv.converte("US", index.pesquisa.get(7).toString())+" 23:59:59\") ";
                conexao.Query("select fr.codigo,fr.cod_matricula, fr.cod_fase,fr.valor_juro_mes,fr.valor_juro_dia,fr.valor_desconto, fr.cod_pessoa, p.descricao as desc_pessoa,fr.parcela, fr.descricao, fr.dt_pagamento,fr.dt_vencimento,fr.valor_bruto,fr.valor_pago,fr.status " + " from fin_contas_mov_r fr inner join pessoas p on p.codigo=fr.cod_pessoa and p.cod_emp=fr.cod_emp " + " where fr.cod_emp=" + index.cod_emp + " " + vdescricao + " " + vpessoa + " " + vtipobusca + " " + vnrdoc + " " + vdtvenc + " " + vdtpag + " " + vvlbr + " " + vvlrec + " " + vturma + " " + vdtpgtoperiodo + " " + vdtvencperiodo + " " + vfase + " order by fr.cod_fase,fr.parcela, fr.dt_pagamento,fr.dt_vencimento DESC");
                int counter = 0;
                while (conexao.rs.next()) {
                    if (conexao.rs.getString("dt_vencimento") != null) {
                        dtTabela1 = new SimpleDateFormat("dd/MM/yyyy").format(conexao.rs.getDate("dt_vencimento"));
                    } else {
                        dtTabela1 = "";
                    }
                    if (conexao.rs.getString("dt_pagamento") != null) {
                        dtTabela2 = new SimpleDateFormat("dd/MM/yyyy").format(conexao.rs.getDate("dt_pagamento"));
                    } else {
                        dtTabela2 = "";
                    }
                    CalculosTabela(conexao.rs.getTimestamp("dt_vencimento"), conexao.rs.getDouble("valor_bruto"), conexao.rs.getString("status"), conexao.rs.getDouble("valor_juro_mes"), conexao.rs.getDouble("valor_juro_dia"), conexao.rs.getDouble("valor_desconto"),conexao.rs.getInt("parcela"));
                    jtb.addRow(new Object[]{conexao.rs.getString("codigo"), conexao.rs.getString("desc_pessoa"), conexao.rs.getString("cod_pessoa"), conexao.rs.getString("parcela"), dtTabela1, index.ftbr.format(conexao.rs.getDouble("valor_bruto")), resJuro, resDesconto, resSaldo, dtTabela2, index.ftbr.format(conexao.rs.getDouble("valor_pago")), resStatus});
                    if (conexao.rs.getString("cod_matricula") != null && busca_direta==false) {
                        if(verificaCarregaTurma(conexao.rs.getString("cod_matricula").toString(), conexao.rs.getString("cod_fase").toString())){
                            cod_turma.add(counter, conexao.rs.getString("cod_matricula")+"/"+conexao.rs.getString("cod_fase"));
                            counter++;
                        }
                    }
                }
                CarregaTurma();
                busca_direta=false;
            } catch (SQLException ex) {
                verErros.setErro(ex.getMessage());
            } catch (ParseException ex) {
                verErros.setErro(ex.getMessage());
            }
        }
    }
    boolean verificaCarregaTurma(String cod_mat, String cod_fa){
        boolean resposta=false;
        boolean achou=false;
        if(cod_turma.size() == 0){
            resposta = true;
        }else{
            for(int i=0;i<cod_turma.size();i++){
                if(cod_turma.get(i).equals(cod_mat+"/"+cod_fa)){
                    achou = true;
                }
            }
            if(achou){
                resposta = false;
            }else{
                resposta = true;
            }
        }
        return resposta;
    }
    private void CarregaTurma(){
        if(jtfTurma.getItemCount()<2){
            jtfTurma.removeAllItems();
            jtfTurma.addItem("Todos");
            for(int i=0;i<cod_turma.size();i++){
                jtfTurma.addItem(cod_turma.get(i));
            }
            cod_turma.removeAll(cod_turma);
        }else{
            cod_turma.removeAll(cod_turma);
        }
    }
    private void setBotoes(){
            jbBaixar.setEnabled(!jbBaixar.isEnabled());
            jbCancelar.setEnabled(!jbCancelar.isEnabled());
            jbEstornar.setEnabled(!jbEstornar.isEnabled());
            jbEditar.setEnabled(!jbEditar.isEnabled());
            jbNegociar.setEnabled(!jbNegociar.isEnabled());
    }
    private void LimpaCarregaObs(){
        javax.swing.table.DefaultTableModel jto = (javax.swing.table.DefaultTableModel)jtObs.getModel();
        for(int x=(jtObs.getRowCount()-1);x>=0; --x ){
            jto.removeRow(x);
        }
    }
    private void CarregaObs(){
        javax.swing.table.DefaultTableModel jto = (javax.swing.table.DefaultTableModel)jtObs.getModel();
        String data;
        CodObs.clear();
        for(int x=(jtObs.getRowCount()-1);x>=0; --x ){
            jto.removeRow(x);
        }
        try {
             conexao.Query("select p.descricao as desc_pessoa,fo.data,fo.descricao,fo.codigo from fin_obs fo " +
                     "   inner join usuarios p on p.codigo=fo.cod_usuario and p.cod_emp=fo.cod_emp" +
                     "   where fo.cod_emp="+index.cod_emp+" and fo.cod_pessoa="+jtCaixa.getValueAt(jtCaixa.getSelectedRow(), 2).toString()+" order by data DESC");
             while(conexao.rs.next()){
                 data = new SimpleDateFormat("dd/MM/yyyy").format(conexao.rs.getDate("data"));
                 CodObs.add(conexao.rs.getString("codigo"));
                 jto.addRow(new Object[]{conexao.rs.getString("desc_pessoa"),data,conexao.rs.getString("descricao")});
             }
             jto.addRow(new Object[]{"",""});
        } catch (SQLException ex) {
             verErros.setErro(ex.getMessage());
        }
    }

    private String resJuro,resSaldo,resDesconto,resStatus;
    private void CalculosTabela(Date tDtInicio, double Saldo, String Status, double JrMes, double JrDia, double Desc, int parc){
        Date dtInicio = tDtInicio;
        Date dtAgora = new Date();
        double resData=(tDtInicio!=null)?((dtAgora.getTime() - dtInicio.getTime()) /86400000L):0.00;
        if(Status.equals("A Receber")||Status.equals("Parcial")){
            if(resData>0){
                resJuro = index.ftbr.format((((Saldo*0.01)/30)*resData)+(Saldo*0.02));
                resSaldo = index.ftbr.format((Saldo+(((Saldo*0.01)/30)*resData)));
                resDesconto = "0,00";
                resStatus = "Vencida";
            }else{
                resJuro = "0,00";
                if(parc > 49){
                    resSaldo = index.ftbr.format(Saldo);
                    resDesconto = index.ftbr.format(0);
                }else{
                    resSaldo = index.ftbr.format((Saldo-(Saldo*0.10)));
                    resDesconto = index.ftbr.format((Saldo*0.10));
                }
                resStatus = Status;
            }
        }else{
            resJuro = index.ftbr.format(JrDia+JrMes);
            resDesconto = index.ftbr.format(Desc);
            if(Desc>0){
                resSaldo = index.ftbr.format((Saldo-(Desc)));
            }else{
                resSaldo = index.ftbr.format((Saldo+(JrDia+JrMes)));
            }
            resStatus = Status;
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JToolBar jToolBar2;
    private javax.swing.JButton jbBaixar;
    private javax.swing.JButton jbCancelar;
    private javax.swing.JButton jbEditar;
    private javax.swing.JButton jbEstornar;
    private javax.swing.JButton jbNegociar;
    private javax.swing.JPanel jpCRPrincipal;
    private javax.swing.JPanel jpMenu;
    private javax.swing.JPanel jpObs;
    private javax.swing.JPanel jpTable;
    private javax.swing.JPopupMenu jpmBoleto;
    private javax.swing.JPopupMenu jpmObs;
    private javax.swing.JScrollPane jspCaixa;
    private javax.swing.JScrollPane jspObs;
    private javax.swing.JTable jtCaixa;
    private javax.swing.JTable jtObs;
    private javax.swing.JComboBox jtfTipoBusca;
    private javax.swing.JComboBox jtfTurma;
    // End of variables declaration//GEN-END:variables

}
